package com.hsh.controller;

import com.hsh.entity.DbDispose;
import com.hsh.persist.BaseController;
import com.hsh.service.IDbDisposeService;
import com.hsh.utils.vo.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.URI;

@Api(value = "DisposeController", tags = "测试管理器")
@RestController
@RequestMapping("/test/dispose")
public class DisposeController extends BaseController {

    @Autowired
    IDbDisposeService disposeService;

    //    @RequiresPermissions("record-apply-for:add")// 按钮权限判定
//    @RequiresRoles("员工") // 角色判定
//    @ApiImplicitParam(name = "Authorization", value = "Authorization", required = true, paramType = "header")
    @ApiOperation(value = "测试删除数据", notes = "测试删除数据", response = TestResult.class)
//    @OperationLog(operation = "删除数据表", exceptionMessage = "系统异常")
    @GetMapping("/{id}")
    public Response test(@PathVariable("id") String id) {
        DbDispose dispose = disposeService.getById(id);
        dispose.setContent(id);
        disposeService.updateById(dispose);
        return Response.success(disposeService.getById(id));
    }

    @GetMapping("/dd")
    public Response dd() {
        return Response.fail(HttpStatus.FORBIDDEN).verror("访问受限，请联系客服");
    }

    @GetMapping("/dd2")
    public Response dd2() {
        return Response.success(new TestResult());
    }


    @GetMapping("/dd3")
    public Response dd3() {
        return Response.fail("没有找到匹配记录").errorCode("访问受限，请联系客服");
    }

    @GetMapping("/dd4")
    public Response dd4() {
        return Response.fail("没有找到匹配记录").verror("访问受限，请联系客服");
    }

    @GetMapping("/dd5")
    public ResponseEntity dd5() {
        return ResponseEntity.ok().body("dadta");
    }

}
